<!DOCTYPE html>
<html lang="zh">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta name="referrer" content="never">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>视频播放器</title>
    <meta name="keywords" content="m3u8在线播放,m3u8,m3u8在线,在线播放,m3u8播放器,mp4在线播放,mp4,mp4在线,mp4播放器"> 
    <meta name="description" content="m3u8在线播放器，mp4在线播放器"> 
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        html,
        body,
        #dplayer {
            width: 100%;
            height: 100%;
            background-color: rgb(1, 0, 1);
        }
        a:link, a:visited {text-decoration: none;}
    </style>
</head>

<body>
    <div id="dplayer"></div>
    <script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/flv.js/dist/flv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dplayer/1.26.0/DPlayer.min.js"></script>
    <script>

        function getUrlParam(name) {
            const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            const r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;

        }

        function getVideoType(url){
            var index= url.lastIndexOf(".");
            return url.substring(index);
        }

        window.onload = () => {
            const url = getUrlParam('url');
            if(url==null){
                console.error('缺少url参数');
                console.info('完整的URL例如:https://zaincheung.gitee.io/video-player/?url=https://sh-download.weiyun.com/ftn_handler/023189b55a76efc5167393c4206770397412dc6d234bcedacdc4f94daf2983a1/4e8367a9adc6d789d29c60b2d0a5ec83.mp4')
                return
            }
            const type = getVideoType(url);
            video = {
                url: url,
                type: 'auto'
            }
            const dp = new DPlayer({
                container: document.getElementById('dplayer'),
                autoplay: true,
                video: video,
            });
        }
    </script>
</body>

</html>